<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2024/4/23
 * Time: 14:20
 */

namespace app\controller\index\withdraw;


use app\controller\index\BaseController;
use app\exception\IndexException;
use app\logic\index\font\FontLogic;
use app\logic\index\withdraw\WithdrawLogic;
use support\Request;
use support\Response;

class IndexController extends BaseController
{
    public function bindWithdrawAccount(Request $request):Response
    {
        $param = [];
        $param['mobile'] = $request->input('mobile');
        $param['truename'] = $request->input('truename');
        $param['account'] = $request->input('account');
        $param['idcard'] = $request->input('idcard');
        $param['authcode'] = $request->input('authcode');
        if(empty($param['mobile'])){
            throw new IndexException(4020,'手机号不能为空');
        }
        if(empty($param['truename'])){
            throw new IndexException(4020,'姓名不能为空');
        }
        if(empty($param['account'])){
            throw new IndexException(4020,'账号不能为空');
        }
        if(empty($param['idcard'])){
            throw new IndexException(4020,'身份证不能为空');
        }
        $data = WithdrawLogic::getInstance()->bindWithdrawAccount($param);
        return $this->endSuccess($data);
    }

    public function getDetail(Request $request):Response
    {
        $param = [];
        $data = WithdrawLogic::getInstance()->getDetail($param);
        return $this->endSuccess($data);
    }

    public function submitWithdraw(Request $request):Response
    {
        $param = [];
        $param['withdraw_amount'] = $request->input('withdraw_amount');
        if(empty($param['withdraw_amount'])){
            throw new IndexException(4020,'提现金额不为空');
        }
        if($param['withdraw_amount']<1){
            throw new IndexException(4020,'提现金额必须大于等于1元');
        }
        $data = WithdrawLogic::getInstance()->submitWithdraw($param);
        return $this->endSuccess($data);
    }

    public function getWithdrawList(Request $request):Response
    {
        $param = [];
        $data = WithdrawLogic::getInstance()->getWithdrawList($param);
        return $this->endSuccess($data);
    }
}